<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta name="keywords" content="EliteCRM, WebChat" />
	<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" />
	<meta name="apple-mobile-web-app-capable" content="yes" />
	<meta name="apple-mobile-web-app-title" content="WebChat" />
    <style type="text/css">
        body, html, #allmap {
            width: 100%;
            height: 100%;
        }
    </style>
    <script type="text/javascript" src="//webapi.amap.com/maps?v=1.3&amp;key=d99a02c6ac01bc15899df46346cbb301"></script> 
    <script type="text/javascript" src="js/jquery/jquery-3.6.0.min.js"></script>
    <title>高德地图</title>
</head>
<body>
<div id="allmap"></div>
</body>
<script type="text/javascript">
	function getParaFromUrl() {
	    var url,pos,parastr,para={};
	    url = window.location.href;
	    pos = url.indexOf("?")
	    parastr = url.substring(pos+1);
	    var paraArr=parastr.split("&");
	    for(var i=0;i<paraArr.length;i++){
	    	var paraOne=paraArr[i];
	    	para[paraOne.substring(0,paraOne.indexOf("="))]=paraOne.substring(paraOne.indexOf("=")+1,paraOne.length);
	    }
		return para;
	}
    
    function setMarkets(map, point, markersStr) {
        try {
            var markers = eval("(" + markersStr + ")");
            for (var i = 0; i < markers.length; i++) {
                var marker = markers[i];
                var label = marker.label;
                
                var marker = new AMap.Marker({
                	position: [marker.la, marker.lo],
                	title: label,
                	icon: "./images/marker_blue.png"
                });
                marker.setMap(map);
                
                marker.addEventListener("click", function () {
                	
                });
                                
            }
        } catch (e) {
            console.error(e);
        }
    }

    $(function () {
    	var aMap = new AMap.Map('allmap', {
    	    center: [117.000923, 36.675807],
    	    zoom: 16
    	});
        var querys = getParaFromUrl();
        var latitude = querys.latitude;
        var longitude = querys.longitude;
        var label = decodeURI(querys.label || '');
        var location = decodeURI(querys.location || '');
        var markersStr = decodeURI(querys.markers || '');
        console.log('Open aMap with position: lat=' + latitude + ', lng=' + longitude + ' , location=' + location + ' , markersStr=' + markersStr);
        var point;
        if (latitude && longitude) {
            latitude = parseFloat(latitude), longitude = parseFloat(longitude);
            aMap.setCenter([longitude, latitude]);
            new AMap.Marker({
            	position: [longitude, latitude],
            	title: label,
            	label: {
            		content: label,
            		offset: new AMap.Pixel(20, -10)
            	},
            	map: aMap
            });
        }

    });
</script>
</html>

